<script type="text/javascript">
    <?php $timestamp = time();?>
    $(function() {
        $('#edit_advert_upload').uploadify({
                    'formData'     : {
                        'timestamp' : '<?php echo $timestamp;?>',
                        'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
                    },
                    'swf'      : '__PUBLIC__/js/uploadify/uploadify.swf',
                    'uploader' : '{:U('Advert/public_upload')}',
                'buttonText': 'advert上传',
                'width'	: 70,
                'height': 26,
                'removeTimeout':0,
                'buttonClass': 'upload_button',
                'onUploadSuccess' : function(file, data, response){
                var data = $.parseJSON(data);
                if(!data.status){
                    $.messager.alert('提示信息', data.info, 'error');
                }else{
                    $('#edit_advert_url').attr('value',data.url);
                    //$.messager.alert('提示信息', data.info, 'info');
                }
            }
        });

        $.formValidator.initConfig({formID:"advertEditForm",theme:'App',onSuccess:advertUploadSave,inIframe:true});
//        $("#edit_advert_version").formValidator({onShow:"请输入版本号",onFocus:"版本号不能为空"}).inputValidator({min:1,max:20,empty:{leftEmpty:false,rightEmpty:false,emptyError:"版本号两边不能有空格"},onError:"版本号不能为空,请确认"});
//        $("#edit_advert_url").formValidator({onShow:"请上传advert",onFocus:"请上传advert"}).inputValidator({min:1,max:200,empty:{leftEmpty:false,rightEmpty:false,emptyError:"url两边不能有空格"},onError:"请上传advert"});
//        $("#edit_advert_descp").formValidator({onShow:"请输入描述",onFocus:"描述不能为空"}).inputValidator({min:1,max:999,onError:"描述不能为空,请确认"});
    });
    function advertUploadSave(){
        $.post('{:U('Advert/advertEdit')}', $("#advertEditForm").serialize(), function(data){
            if(!data.status){
                $.messager.alert('提示信息', data.info, 'error');
            }else{
                advertRefreshList();
                $.messager.alert('提示信息', data.info, 'info');
                $('#advertEditBox').dialog('close');
            }
        })
    }
    function buildFace(val,row,index){
        if(!val){
            return '<div style="height:60px;padding:3px;margin:auto;"></div>';
        }else{
            return '<div style="padding:3px;"><img src="'+val+'" height="60" style="padding:1px;border:1px solid #ccc;"></div>';
        }
    }

</script>
<form id="advertEditForm" style="padding-top: 10px; padding-left: 5px;">
    <table id="advertEditBox">
        <tr>
            <td width="100" align="center">说明：</td>
            <td><input type="text" id="edit_advert_version"
                       name="info[remark]" value="{$info.remark}" style="width: 450px; height: 20px;"></td>
            <td><div id="edit_advert_versionTip"></div></td>
        </tr>
        <tr>
            <td width="100" align="center">图片链接：</td>
            <td><input type="text" id="edit_advert_imghref"
                       name="info[imghref]" value="{$info.imghref}" style="width: 450px; height: 20px;"></td>
            <td><div id="edit_advert_imghrefTip"></div></td>
        </tr>
        <tr>
            <td width="100" align="center">图片地址</td>
            <td><input type="text" id="edit_advert_url" name="info[imgurl]"
                       value="{$info.imgurl}" readonly="readonly" style="width: 450px;height: 20px;" onchange="v()"></td>
            <td><div id="edit_advert_urlTip"></div></td>
        </tr>
        <tr>
            <td width="100"></td>
            <td>
                <div id="queue"></div> <input id="edit_advert_upload" name="edit_advert_upload"
                                              type="file" multiple="false">
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <input type="hidden" name="info[id]" value="{$info.id}">
            </td>
        </tr>
    </table>
</form>